package com.qf.service.impl;

import com.qf.entity.OrderRefund;
import com.qf.entity.OrderRefundDTO;
import com.qf.entity.OrderRefundDetail;
import com.qf.entity.OrderRefundVO;
import com.qf.mapper.OrderMapper;
import com.qf.mapper.OrderRefundDetailMapper;
import com.qf.mapper.OrderRefundVOMapper;
import com.qf.mapper.UserMapper;
import com.qf.service.OrderRefundVOService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * 天--道--酬--勤
 *
 * @author LiangGaoQiang
 * @ClassName OrderRefundVOServiceImpl
 * @Date: 2025/5/2 16:52
 * @Description: 描述
 */
@Service
public class OrderRefundVOServiceImpl implements OrderRefundVOService {
    @Autowired
    private OrderRefundVOMapper orderRefundVOMapper;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private OrderMapper orderMapper;
    private OrderRefundDetailMapper orderRefundDetailMapper;


    @Override
    public List<OrderRefundVO> queryAllOrderRefundVO(OrderRefundDTO orderRefundDTO) {
        return orderRefundVOMapper.queryAllOrderRefundVO(orderRefundDTO);
    }

    @Override
    public boolean addOrderRefundVO(OrderRefund orderRefund) {
        // 根据username和orderNo查询用户表和订单表中中的id
        Long uid = userMapper.getIdByUserName(orderRefund.getUsername());
        Long oid = orderMapper.getIdByOrderNo(orderRefund.getOrderNo());
        // 设置订单退款表中的userId和orderId
        orderRefund.setUserId(uid);
        orderRefund.setOrderId(oid);
        return orderRefundVOMapper.addOrderRefundVO(orderRefund);
    }
}
